package com.heima.behavior.controller;

import com.heima.behavior.service.ApUnlikesBehaviorService;
import com.heima.behavior.service.ApLikesBehaviorService;
import com.heima.behavior.service.ApReadBehaviorService;
import com.heima.common.dtos.ResponseResult;
import com.heima.common.threadlocal.UserThreadLocalUtils;
import com.heima.model.behavior.dtos.UnLikesBehaviorDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import com.heima.model.behavior.dtos.LikesBehaviorDto;
import org.springframework.beans.factory.annotation.Autowired;
import com.heima.model.behavior.dtos.ReadBehaviorDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
@Api(tags = "用户行为服务相关接口")
@RestController
public class BehaviorController {
    @Autowired
    private ApReadBehaviorService readBehaviorService;

    @Autowired
    private ApUnlikesBehaviorService unlikesBehaviorService;
    @Autowired
    private ApLikesBehaviorService apLikesBehaviorService;
    /**
     * 用户不喜欢行为接口
     */
    @ApiOperation("不喜欢")
    @PostMapping("/api/v1/unlike_behavior")
    public ResponseResult unlikeBehavior(@RequestBody UnLikesBehaviorDto dto){
        unlikesBehaviorService.unlikeBehavior(dto);
        return ResponseResult.ok();
    }

    /**
     * 阅读行为
     * @param dto
     * @return
     */
    @PostMapping("/api/v1/read_behavior")
    public ResponseResult readBehavior(@RequestBody ReadBehaviorDto dto) {
        readBehaviorService.readBehavior(dto);
        return ResponseResult.ok();
    }

    /**
     * 点赞
     * @param dto
     * @return
     */
    @PostMapping("/api/v1/likes_behavior")
    public ResponseResult likesBehavior(@RequestBody LikesBehaviorDto dto) {
        apLikesBehaviorService.likesBehavior(dto);
        return ResponseResult.ok();
    }

}
